package com.sfeir.gwt.webding.client.component.menu;

import com.google.gwt.user.client.History;
import com.google.gwt.user.client.ui.AbstractImagePrototype;

/**
 * Une entree de menu qui permet de demarer un processus
 * 
 *
 */
public class ItemHyperlink extends Item {

    public static final String TYPE = "hyperlink";
    /**
     * 
     */
    private static final long serialVersionUID = 7951955050127004088L;
    private String targetHistoryToken;
    
    public ItemHyperlink(String label, String targetHistoryToken) {
        super(label, "#" + targetHistoryToken, TYPE);
        this.setTargetHistoryToken(targetHistoryToken);
    }
    
    public ItemHyperlink(String label, String targetHistoryToken, String icon) {
        super(label, "#" + targetHistoryToken, TYPE, icon);
        this.setTargetHistoryToken(targetHistoryToken);
    }
    
    public ItemHyperlink(String label, String targetHistoryToken, AbstractImagePrototype icon) {
        super(label, "#" + targetHistoryToken, TYPE, icon);
        this.setTargetHistoryToken(targetHistoryToken);
    }
    
    public void setTargetHistoryToken(String targetHistoryToken) {
        this.targetHistoryToken = targetHistoryToken;
    }

    public String getTargetHistoryToken() {
        return targetHistoryToken;
    }
    
    @Override
    public void exec() {
        History.newItem(targetHistoryToken);
    }
}
